home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / NUMBERS.SWG / 0067_Bits is Bits.pas < prev   
Pascal/Delphi Source File  |  1995-02-28  |  717b  |  43 lines

  1.  
  2. program test {also untested};
  3.  
  4. var
  5.   testbyte: byte;
  6.  
  7. function testbit(testbyte,bit:byte):boolean; assembler;
  8. asm
  9.   mov  cl,bit
  10.   mov  ah,1
  11.   shl  ah,cl
  12.   mov  al,testbyte
  13.   and  al,ah
  14. end;
  15.  
  16. procedure setbit(var testbyte:byte; bit:byte); assembler;
  17. asm
  18.   mov  cl,bit
  19.   mov  al,1
  20.   shl  al,cl
  21.   les  di,[testbyte]
  22.   or   [es:di],al
  23. end;
  24.  
  25. procedure clearbit(var testbyte:byte; bit:byte); assembler;
  26. asm
  27.   mov  cl,bit
  28.   mov  al,1
  29.   shl  al,cl
  30.   not  al
  31.   les  di,[testbyte]
  32.   and  [es:di],al
  33. end;
  34.  
  35. begin
  36.   testbyte := 0;
  37.   setbit(testbyte,2);
  38.   setbit(testbyte,5);
  39.   if testbit(testbyte,2) then writeln('2 is ON');
  40.   if not testbit(testbyte,3) then writeln('3 is OFF');
  41. end.
  42.  
  43.